import model from '../../models/cookbookModel'

// 初始化swiper数据
export const initSwiper = () => async (dispatch) => {
  let ret = await model.getSwiperData()
  dispatch({
    type: 'initSwiper',
    // 普通js对象
    data: ret.data.data
  })
}

// 热门分类
export const getHotCateData = () => async (dispatch) => {
  let data = await model.getHotCateData()
  dispatch({
    type: 'setHotcate',
    // 普通js对象
    data
  })
}

// 精品菜谱
export const getGoodCookbookData = (size = 10) => async (dispatch) => {
  let data = await model.getGoodCookbookData()
  dispatch({
    type: 'setGoodCookbook',
    // 普通js对象
    data
  })
}

// 分类
export const getCategoryData = () => async (dispatch) => {
  let data = await model.getCategoryData()
  dispatch({
    type: 'setCategoryData',
    data
  })
}
// 食材
export const getMaterialData = () => async (dispatch) => {
  let data = await model.getMaterialData()
  dispatch({
    type: 'setMaterialData',
    data
  })
}

// 菜单隐藏
export const setFooterMenu = (data = '') => ({
  type: 'setFooterMenu',
  data
})


